package com.sinven.daoImpl;

import com.sinven.dao.TopicDao;
import com.sinven.entity.Topic;
import com.sinven.util.HibernateUtil;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 李志伟
 */
@Repository
public class TopicDaoImpl extends HibernateDaoSupport implements TopicDao {
    public TopicDaoImpl(){}

    @Autowired
    public TopicDaoImpl(@Qualifier("sessionFactory")SessionFactory sessionFactory){
        this.setSessionFactory(sessionFactory);
    }


    @Override
    public Integer savaTopic(Topic topic, String hql) {
        return null;
    }



    @Override
    public List<Topic> findById(int id, String hql) {
        Session session= HibernateUtil.getSession();
        Query query=session.createQuery(hql);
        query.setParameter(1,id);
        return query.list();
    }

    @Override
    public void addTop(Topic topic) {

    }

    @Override
    public void updataTop(Topic topic) {

    }

    @Override
    public void delectTop(int id) {

    }
}
